#! /bin/sh

#-----------------------------------------------------------------------------
# WineLocale
#
# This script adds related locales to the system's supported tables. We do
# not simply install locales out of Ubuntu because, frankly, Ubuntu's locale
# packages suck. Most do not even give users the following encodings, and
# where they do, they come with hundreds of megabytes of unnecessary files.
#-----------------------------------------------------------------------------

set -e

case "$1" in
    configure)
        cd /var/lib/locales/supported.d ;
        touch ar el he ja ko ru zh ;

        # Add Arabic codepages
        if [ "`cat ar | grep 'ar_SA.UTF-8 UTF-8'`" = "" ]; then
            echo "ar_SA.UTF-8 UTF-8" >>ar ;
        fi ;
        if [ "`cat ar | grep 'ar_SA.ISO-8859-6 ISO-8859-6'`" = "" ]; then
            echo "ar_SA.ISO-8859-6 ISO-8859-6" >>ar ;
        fi ;

        # Add Greek codepages
        if [ "`cat el | grep 'el_GR.UTF-8 UTF-8'`" = "" ]; then
            echo "el_GR.UTF-8 UTF-8" >>el ;
        fi ;
        if [ "`cat el | grep 'el_GR.ISO-8859-7 ISO-8859-7'`" = "" ]; then
            echo "el_GR.ISO-8859-7 ISO-8859-7" >>el ;
        fi ;

        # Add Hebrew codepages
        if [ "`cat he | grep 'he_IL.UTF-8 UTF-8'`" = "" ]; then
            echo "he_IL.UTF-8 UTF-8" >>he ;
        fi ;
        if [ "`cat he | grep 'he_IL.ISO-8859-8 ISO-8859-8'`" = "" ]; then
            echo "he_IL.ISO-8859-8 ISO-8859-8" >>he ;
        fi ;

        # Add Japanese codepages
        if [ "`cat ja | grep 'ja_JP.UTF-8 UTF-8'`" = "" ]; then
            echo "ja_JP.UTF-8 UTF-8" >>ja ;
        fi ;
        if [ "`cat ja | grep 'ja_JP SJIS'`" = "" ]; then
            echo "ja_JP SJIS" >>ja ;
        fi ;
        if [ "`cat ja | grep 'ja_JP.EUC-JP EUC-JP'`" = "" ]; then
            echo "ja_JP.EUC-JP EUC-JP" >>ja ;
        fi ;

        # Add Korean codepages
        if [ "`cat ko | grep 'ko_KR.UTF-8 UTF-8'`" = "" ]; then
            echo "ko_KR.UTF-8 UTF-8" >>ko ;
        fi ;
        if [ "`cat ko | grep 'ko_KR.EUC-KR EUC-KR'`" = "" ]; then
            echo "ko_KR.EUC-KR EUC-KR" >>ko ;
        fi ;

        # Add Russian codepages
        if [ "`cat ru | grep 'ru_RU.UTF-8 UTF-8'`" = "" ]; then
            echo "ru_RU.UTF-8 UTF-8" >>ru ;
        fi ;
        if [ "`cat ru | grep 'ru_UA.UTF-8 UTF-8'`" = "" ]; then
            echo "ru_UA.UTF-8 UTF-8" >>ru ;
        fi ;
        if [ "`cat ru | grep 'ru_RU.ISO-8859-5 ISO-8859-5'`" = "" ]; then
            echo "ru_RU.ISO-8859-5 ISO-8859-5" >>ru ;
        fi ;
        if [ "`cat ru | grep 'ru_UA.ISO-8859-5 ISO-8859-5'`" = "" ]; then
            echo "ru_UA.ISO-8859-5 ISO-8859-5" >>ru ;
        fi ;

        # Add Chinese codepages
        if [ "`cat zh | grep 'zh_CN.UTF-8 UTF-8'`" = "" ]; then
            echo "zh_CN.UTF-8 UTF-8" >>zh ;
        fi ;
        if [ "`cat zh | grep 'zh_TW.UTF-8 UTF-8'`" = "" ]; then
            echo "zh_TW.UTF-8 UTF-8" >>zh ;
        fi ;
        if [ "`cat zh | grep 'zh_CN GB2312'`" = "" ]; then
            echo "zh_CN GB2312" >>zh ;
        fi ;
        if [ "`cat zh | grep 'zh_CN.GB18030 GB18030'`" = "" ]; then
            echo "zh_CN.GB18030 GB18030" >>zh ;
        fi ;
        if [ "`cat zh | grep 'zh_TW Big5'`" = "" ]; then
            echo "zh_TW Big5" >>zh ;
        fi ;

        dpkg-reconfigure locales ;
        ;;

    abort-upgrade|abort-remove|abort-deconfigure)

    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

